<?php

class Control_Model_Table_Testimonials extends Zend_Db_Table_Abstract
{
    protected $_name = 'testimonials_content';
    
    public function getAll()
    {
        $select = $this->select();
        $select->order('id ASC');
//               ->where('position>0');
        $Content = $this->_db->query($select)->fetchAll();
        return $Content;
    }

            public function getDataID($id)
    {
        $id = (int)$id;
        $row = $this->fetchRow('id ='.$id);
        if (!$row) {
 //           throw new Exception("Count not find row $id");
        }else{return $row->toArray();}
    }

        public function addData($author, $text, $link)
    {
        $data = array(
            'author' => $author,
            'text' => $text,
            'link' => $link);
        $this->insert($data);
    }

        public function updateData($id, $author, $text, $link)
    {
        $data = array(
            'author' => $author,
            'text' => $text,
            'link' => $link);
        $this->update($data,'id= '.(int)$id);
    }

            public function deleteData($id)
    {
        $this->delete('id ='.(int)$id);
    }

}

